Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 20: Lighting Your World

../ch20/20fig17b.gif
Figure 20.17b

A simple world with fake shadows. Compare with Figure 20.17a.

20fig17b.wrl
Click on the image to view the VRML scene.

#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
    children [
    # Lighting
        DirectionalLight {
            direction 0.0 -1.0 0.0
            ambientIntensity 0.5
        },
    # Floor
        Shape {
            appearance Appearance {
                material Material { }
            }
            geometry Box { size 8.0 0.01 8.0 }
        },
    # Spheres and fake shadows
        Transform {
            translation 0.0 4.0 2.0
            children [
                Shape {
                    appearance Appearance {
                        material Material { diffuseColor 1.0 1.0 0.0 }
                    }
                    geometry Sphere { }
                },
            # Shadow
                Transform {
                    translation 0.0 -3.95 0.0
                    children Shape {
                        appearance DEF ShadowAppearance Appearance {
                            material Material {
                                diffuseColor 0.0 0.0 0.0
                                transparency 0.5
                            }
                        }
                        geometry Cylinder {
                            height 0.0
                            side   FALSE
                            bottom FALSE
                        }
                    }
                }
            ]
        },
        Transform {
            translation 2.0 2.0 -2.0
            children [
                Shape {
                    appearance Appearance {
                        material Material { diffuseColor 0.0 1.0 0.0 }
                    }
                    geometry Sphere { radius 2.0 }
                },
            # Shadow
                Transform {
                    translation 0.0 -1.95 0.0
                    children Shape {
                        appearance USE ShadowAppearance
                        geometry Cylinder {
                            radius 2.0
                            height 0.0
                            side   FALSE
                            bottom FALSE
                        }
                    }
                }
            ]
        },
        Transform {
            translation -2.0 2.5 0.0
            children [
                Shape {
                    appearance Appearance {
                        material Material { diffuseColor 0.0 1.0 1.0 }
                    }
                    geometry Sphere { radius 0.75 }
                },
            # Shadow
                Transform {
                    translation 0.0 -2.45 0.0
                    children Shape {
                        appearance USE ShadowAppearance
                        geometry Cylinder {
                            radius 0.75
                            height 0.0
                            side   FALSE
                            bottom FALSE
                        }
                    }
                }
            ]
        }
    ]
}